<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Publish a message to an exchange.</title>

 </head>
 <body><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="amqpexchange.gettype.html">AMQPExchange::getType</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="amqpexchange.setargument.html">AMQPExchange::setArgument</a></div>
 <div class="up"><a href="class.amqpexchange.html">AMQPExchange</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div><hr /><div id="amqpexchange.publish" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">AMQPExchange::publish</h1>
  <p class="verinfo">(PECL amqp &gt;= Unknown)</p><p class="refpurpose"><span class="refname">AMQPExchange::publish</span> &mdash; <span class="dc-title">Publish a message to an exchange.</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-amqpexchange.publish-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="type">bool</span> <span class="methodname"><strong>AMQPExchange::publish</strong></span>
    ( <span class="methodparam"><span class="type">string</span> <code class="parameter">$message</code></span>
   , <span class="methodparam"><span class="type">string</span> <code class="parameter">$routing_key</code></span>
   [, <span class="methodparam"><span class="type">int</span> <code class="parameter">$flags</code><span class="initializer"> = <strong><code>AMQP_NOPARAM</code></strong></span></span>
   [, <span class="methodparam"><span class="type">array</span> <code class="parameter">$attributes</code><span class="initializer"> = array()</span></span>
  ]] )</div>

  <p class="para rdfs-comment">
    Publish a message to the exchange represented by the <a href="class.amqpexchange.html" class="classname">AMQPExchange</a> object.
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-amqpexchange.publish-parameters">
  <h3 class="title">参数</h3>
  <p class="para">
   <dl>

    
     <dt>
<em><code class="parameter">message</code></em></dt>

     <dd>

      <p class="para">
       The message to publish.
      </p>
     </dd>

    
    
     <dt>
<em><code class="parameter">routing_key</code></em></dt>

     <dd>

      <p class="para">
       The routing key to which to publish.
      </p>
     </dd>

    
    
     <dt>
<em><code class="parameter">flags</code></em></dt>

     <dd>

      <p class="para">
       One or more of <strong><code>AMQP_MANDATORY</code></strong> and
       <strong><code>AMQP_IMMEDIATE</code></strong>.
      </p>
     </dd>

    
    
     <dt>
<em><code class="parameter">attributes</code></em></dt>

     <dd>

      <p class="para">
       <table class="doctable table">
        <caption><strong>Supported indexes</strong></caption>
        
         <thead>
          <tr>
           <th>key</th>
           <th>Description</th>
           <th>Default value</th>
          </tr>

         </thead>

         <tbody class="tbody">
          <tr>
           <td><em class="emphasis">content_type</em></td>
           <td class="empty">&nbsp;</td>
           <td><em>text/plain</em></td>
          </tr>

          <tr>
           <td><em class="emphasis">content_encoding</em></td>
           <td class="empty">&nbsp;</td>
           <td>NULL</td>
          </tr>

          <tr>
           <td><em class="emphasis">message_id</em></td>
           <td class="empty">&nbsp;</td>
           <td>NULL</td>
          </tr>

          <tr>
           <td><em class="emphasis">user_id</em></td>
           <td class="empty">&nbsp;</td>
           <td>NULL</td>
          </tr>

          <tr>
           <td><em class="emphasis">app_id</em></td>
           <td class="empty">&nbsp;</td>
           <td>NULL</td>
          </tr>

          <tr>
           <td><em class="emphasis">delivery_mode</em></td>
           <td class="empty">&nbsp;</td>
           <td>NULL</td>
          </tr>

          <tr>
           <td><em class="emphasis">priority</em></td>
           <td class="empty">&nbsp;</td>
           <td>NULL</td>
          </tr>

          <tr>
           <td><em class="emphasis">timestamp</em></td>
           <td class="empty">&nbsp;</td>
           <td>NULL</td>
          </tr>

          <tr>
           <td><em class="emphasis">expiration</em></td>
           <td>time in milliseconds</td>
           <td>NULL</td>
          </tr>

          <tr>
           <td><em class="emphasis">type</em></td>
           <td class="empty">&nbsp;</td>
           <td>NULL</td>
          </tr>

          <tr>
           <td><em class="emphasis">reply_to</em></td>
           <td class="empty">&nbsp;</td>
           <td>NULL</td>
          </tr>

          <tr>
           <td><em class="emphasis">headers</em></td>
           <td>custom attributes to pass along with message</td>
           <td>array</td>
          </tr>
          
         </tbody>
        
       </table>

      </p>
     </dd>

    
   </dl>

  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-amqpexchange.publish-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   成功时返回 <strong><code>TRUE</code></strong>， 或者在失败时返回 <strong><code>FALSE</code></strong>。
  </p>
 </div>


 <div class="refsect1 errors" id="refsect1-amqpexchange.publish-errors">
  <h3 class="title">错误／异常</h3>
  <p class="para">
   Throws an <strong class="classname">AMQPExchangeException</strong> on failure.
  </p>
  <p class="para">
   Throws <strong class="classname">AMQPChannelException</strong> if the channel is not open.
  </p>
  <p class="para">
   Throws <strong class="classname">AMQPConnectionException</strong> if the connection to the broker was lost.
  </p>
 </div>


</div><hr /><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="amqpexchange.gettype.html">AMQPExchange::getType</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="amqpexchange.setargument.html">AMQPExchange::setArgument</a></div>
 <div class="up"><a href="class.amqpexchange.html">AMQPExchange</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div></body></html>
